package com.lis.springboot_lis.exception;

import com.lis.springboot_lis.pojo.ResponseMessage;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


@RestControllerAdvice //统一处理
public class GlobalExceptionHandleAdvice {

    Logger log = LoggerFactory.getLogger(GlobalExceptionHandleAdvice.class);
    @ExceptionHandler(value = Exception.class)
    public ResponseMessage handleException(Exception e, HttpServletRequest request, HttpServletResponse response) {
        //记录日志



        log.error("统一异常:",e);
        return new ResponseMessage(500,"error",null);
    }
}
